package com.ado.abyss.core.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ado.abyss.core.params.page.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ado.abyss.core.dal.model.SysDict;
import com.ado.abyss.core.manager.SysDictManager;
import com.ado.abyss.core.service.SysDictService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * 
 * @author adonais
 * @date 2020/06/08
 * @description 字典业务接口实现
 *
 */
@Service(value = "sysDictService")
public class SysDictServiceImpl implements SysDictService{
	
	
	@Autowired
	@Qualifier(value = "sysDictManager")
	private SysDictManager sysDictManager ;

	@Override
	public List<SysDict> findByLabel(String label) {
		List<SysDict> sysDicts = sysDictManager.findByLabel(label) ;
		return sysDicts;
	}

	@Override
	public boolean save(SysDict record) {
		boolean flag = sysDictManager.saveDict(record) ;
		return flag;
	}

	@Override
	public boolean delete(List<SysDict> records) {
		List<Long> list = new ArrayList<Long>() ;
		for (SysDict sysDict : records) {
			list.add(sysDict.getId()) ;
		}
		boolean flag = sysDictManager.deleteByIds(list) ;
 		return flag;
	}

	@Override
	public PageInfo<SysDict> findPage(PageRequest pageRequest) {
		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize()) ;
		List<SysDict> sysDicts = sysDictManager.findAll() ;
		return new PageInfo<SysDict>(sysDicts);
	}

	
}
